package com.wyc.serviceDriverUser.controller;

import com.wyc.internalCommon.result.ApiResult;
import com.wyc.serviceDriverUser.dto.DriverUser;
import com.wyc.serviceDriverUser.service.DriverUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 司机信息Controller
 * 
 * @author li
 * @date 2023-03-25
 */
@RestController
public class DriverUserController
{
    @Autowired
    private DriverUserService driverUserService;


    /**
     * 根据手机号查询司机是否存在  1
     * @param driverPhone
     * @return
     */
    @PostMapping("/check-driver/{driverPhone}")
    public ApiResult query(@PathVariable("driverPhone") String driverPhone){
        return driverUserService.query(driverPhone);
    }

    /**
     * 司机列表
     * @return
     */
    @GetMapping("/driver-user-list")
    public ApiResult list(){
        return driverUserService.list();
    }

    /**
     * 新增或修改司机信息
     * @param driverUser
     * @return
     */
    @PostMapping("/user")
    public ApiResult insertOrUpdate(@RequestBody DriverUser driverUser){
        return driverUserService.insertOrUpdateDriverUser(driverUser);
    }

    /**
     * 通过试图查询当前城市是否有司机。
     * @param cityCode
     * @return
     */
    @GetMapping("/driver-status/{cityCode}")
    public ApiResult<Boolean> queryDriverByCityCode(@PathVariable("cityCode") String cityCode){
        return driverUserService.queryDriverByCityCode(cityCode);
    }

}
